package com.kingschan.jeasytag.tag.grid;
import javax.servlet.jsp.JspException;
import com.kingschan.jeasytag.core.annotations.tag.*;
import com.kingschan.jeasytag.tag.RootTag;
/**
 * 普通列
 * @author kingschan
 *2013-4-6
 */
@TagMetaData(CssClass = "", tag = "th"
)
public class ColumnTag extends RootTag implements Cloneable{

	private static final long serialVersionUID = 1L;
	@PropertyField
	@StringField(description="生成控件类型",Regex="[text]{4}|[select]{6}|[number]{6}|[date]{4}|[datetime]{8}")
	private String inputtype;
	@PropertyField
	@StringField(description="初始数据")
	private String data;
	@PropertyField
	@BooleanField(description="此列为固定列")
	private String frozen;
	@StringField(description="列标题")
	private String title ;
	@StringField(description="列字段")
	private String field;
	@NumberField(description="列宽")
	private String width;
	@NumberField(description="表明一个单元格跨几行")
	private String rowspan;
	@NumberField(description="表明一个单元格跨几列")
	private String colspan;
	@StringField(description="表明如何对其列数据，可选值：'left'，'right'，'center'")
	private String align;
	@BooleanField(description="设置为true允许对该列排序")
	private String sortable;
	@BooleanField(description="设置为true允许该列被缩放")
	private String resizable;
	@BooleanField(description="设置为true将隐藏列")
	private String hidden;
	@BooleanField(description="设置为true将显示复选框")
	private String checkbox;
	@EventField(args={"value"},description="格式化单元格函数，有3个参数：	value：字段的值。	rowData：行数据。rowIndex：行索引。")
	private String formatter ;  
	@EventField(args={"value","rowData","rowIndex"},description="单元格样式函数，返回样式字符串装饰表格如'background:red'，function有3个参数：	value：字段值。	rowData：行数据。	rowIndex：行索引。")
	private String styler ;
	@PropertyField
	@JsonField(description="表明编辑类型。如果属性是字符串类型表示编辑类型，如果是对象则包含2个参数：type：字符串，编辑类型，可选值：text，textarea，checkbox，numberbox，validatebox，datebox，combobox，combotree。options：对象，对象于编辑类型的编辑器属性。")
	private String editor;



	@Override
	protected Object clone() throws CloneNotSupportedException {		
		return super.clone();
	}
	@Override
	public int doStartTag() throws JspException {

		try {

			String className=this.getParent().getClass().getSimpleName();
			if (className.equals("TreeGrid")) {
				TreeGrid tree = (TreeGrid) this.getParent();
				ColumnTag ct = (ColumnTag) this.clone();
				tree.addColumn(ct);
			}else if (className.equals("GridTag")) {
				GridTag grid = (GridTag)this.getParent();
				ColumnTag ct = (ColumnTag) this.clone();
				grid.addColumn(ct);
			}

		} catch (CloneNotSupportedException e) {			
			e.printStackTrace();
		}
		return super.doStartTag();
	}

	public String getTitle() {
		return title;
	}


	public void setTitle(String title) {
		this.title = title;
	}


	public String getField() {
		return field;
	}


	public void setField(String field) {
		this.field = field;
	}


	public String getWidth() {
		return width;
	}


	public void setWidth(String width) {
		this.width = width;
	}


	public String getRowspan() {
		return rowspan;
	}


	public void setRowspan(String rowspan) {
		this.rowspan = rowspan;
	}


	public String getColspan() {
		return colspan;
	}


	public void setColspan(String colspan) {
		this.colspan = colspan;
	}


	public String getAlign() {
		return align;
	}


	public void setAlign(String align) {
		this.align = align;
	}


	public String getSortable() {
		return sortable;
	}


	public void setSortable(String sortable) {
		this.sortable = sortable;
	}


	public String getResizable() {
		return resizable;
	}


	public void setResizable(String resizable) {
		this.resizable = resizable;
	}


	public String getHidden() {
		return hidden;
	}


	public void setHidden(String hidden) {
		this.hidden = hidden;
	}


	public String getCheckbox() {
		return checkbox;
	}


	public void setCheckbox(String checkbox) {
		this.checkbox = checkbox;
	}


	public String getFormatter() {
		return formatter;
	}


	public void setFormatter(String formatter) {
		this.formatter = formatter;
	}


	public String getStyler() {
		return styler;
	}


	public void setStyler(String styler) {
		this.styler = styler;
	}


	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String getFrozen() {
		return frozen;
	}

	public void setFrozen(String frozen) {
		this.frozen = frozen;
	}

	public String getInputtype() {
		return inputtype;
	}

	public void setInputtype(String inputtype) {
		this.inputtype = inputtype;
	}

	public String getData() {
		return data;
	}

	public void setData(String data) {
		this.data = data;
	}

	public String getEditor() {
		return editor;
	}

	public void setEditor(String editor) {
		this.editor = editor;
	}




}
